package com.googlecode.jerato.library.view.xml;

import java.io.Writer;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;


public class XmlViewNodeList extends XmlViewNode {
	protected String _listName;

	public void render(Writer writer, Map map){
		if(_listName == null){
			return;
		}

		Object listObj = map.get(_listName);
		if(!(listObj instanceof List)){
			return;
		}
		List list = (List)listObj;
		for(Iterator listItr = list.iterator(); listItr.hasNext(); ){
			Map childMap = (Map)listItr.next();
			HashMap tempMap = new HashMap();
			tempMap.putAll(map);
			tempMap.putAll(childMap);
			for(Iterator itr = iterator(); itr.hasNext(); ){
				XmlViewNode node = (XmlViewNode)itr.next();
				node.render(writer, childMap);
			}
		}
	}

	public String getListName() {
		return _listName;
	}

	public void setListName(String name) {
		_listName = name;
	}

}
